package org.jetlinks.community.mstn.entity.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec;
import org.jetlinks.community.device.entity.DeviceInstanceEntity;
import org.jetlinks.community.mstn.entity.DeviceAliasEntity;
import org.jetlinks.community.mstn.enums.DataSourceType;

import javax.persistence.Column;
import java.sql.JDBCType;
import java.util.Map;

@Data
public class DeviceAliasCreateReqVO {


    @Schema(description = "分类ID")
    private String categoryId;

    @Schema(description = "分类名")
    private String categoryName;

    @Column(name = "nickname")
    @Schema(description = "别名")
    private String nickname;

    @Schema(description = "站点ID")
    private String siteId;

    @Schema(description = "分组ID")
    private String groupId;

    @Schema(description = "保养间隔")
    private Long interval;

    @Schema(description = "安装时间")
    private Long installTime;

    @Schema(description = "说明")
    private String describe;

    @Schema(description = "数据源类型")
    private DataSourceType dataSourceType;

    @Schema(description = "物模型")
    private String aliasMetadata;

    @Schema(description = "配置信息")
    private Map<String, Object> configuration;


    public DeviceAliasEntity toEntity() {
        DeviceAliasEntity entity = new DeviceAliasEntity();
        entity.setNickname(nickname);
        entity.setSiteId(siteId);
        entity.setGroupId(groupId);
        entity.setInterval(interval);
        entity.setInstallTime(installTime);
        entity.setDescribe(describe);
        entity.setDataSourceType(dataSourceType);
        entity.setAliasMetadata(aliasMetadata);
        entity.setConfiguration(configuration);
        return entity;
    }

    /**
     * 修改设备信息
     * @return
     */
    public DeviceInstanceEntity toDeviceInstanceEntity() {
        DeviceInstanceEntity entity = new DeviceInstanceEntity();
        entity.setNickname(nickname);
        entity.setDescribe(describe);
        entity.setConfiguration(configuration);
        return entity;
    }
}
